﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NetworkSimulator
{
    public class IEList
    {
        private List<IngressEgress> ieList = new List<IngressEgress>();

        private Topology map = Topology.instance();

        public List<IngressEgress> IngressEgressList
        {
            get { return this.ieList; }
        }

        public IngressEgress this[int i]
        {
            get { return ieList[i]; }
            set { ieList[i] = value; }
        }

        // Synchronize object
        public static object lockingObject = new object();

        public static IEList singletonIEList;

        public static IEList instance()
        {
            if (singletonIEList == null)
            {
                lock (lockingObject)
                {
                    if (singletonIEList == null)
                        singletonIEList = new IEList();
                }
            }
            return singletonIEList;
        }

        public IEList()
        {
            loadIEListData();
        }

        private void loadIEListData()
        {
            IngressEgress ie1 = new IngressEgress(map.Nodes[0], map.Nodes[12]);
            IngressEgress ie2 = new IngressEgress(map.Nodes[4], map.Nodes[8]);
            IngressEgress ie3 = new IngressEgress(map.Nodes[3], map.Nodes[1]);
            IngressEgress ie4 = new IngressEgress(map.Nodes[4], map.Nodes[14]);
            ieList.Add(ie1);
            ieList.Add(ie2);
            ieList.Add(ie3);
            ieList.Add(ie4);
        }
    }
}
